const mysql = require('mysql2');

const connectionPoll =  mysql.createPool({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'Cqgoat201718',
    database: 'user_db',
    connectionLimit:5
})

//验证是否连接成功
connectionPoll.getConnection((err, con) => {
    if (err)
    {
        console.log("数据库连接失败");    
        return;
    }
    
    con.connect((err) => {
        if (err)
        {
            console.log("和数据库交互失败");    
        }
        else {
            console.log("和数据库交互成功");
        }
    })
    
})


module.exports = connectionPoll;